<template>
	<view>
		<scroll-view :scroll-y="true" class="scorll-height"
		
		>
		<view class="">
			<view class="flex-content" style="margin-top: 72rpx;">
				<view class="" @click="routerNext(1)">
					<view class="flex-content" >
						<image style="width:168rpx ;" src="../../static/Get-cash.png" mode="widthFix"></image>
						
					</view>
					<view class="m-t-28" style="color: #775738;">
						邀好友送现金
					</view>
				</view>
				<view class="" style="margin-left: 200rpx;"  @click="routerNext(2)">
					<view class="flex-content">
						<image style="width:148rpx ;" src="../../static/exchange-preferential.png" mode="widthFix"></image>
						
					</view>
					<view class="m-t-28" style="color: #775738;">
						优惠券兑换
					</view>
				</view>
				
			</view>
			<view class="p-b-30">
				<block v-for="(item,index) in list" :key="index">
				<discounts-list :item="item" @setCoupon="setCoupon" :index="index" type="1" ></discounts-list>
				</block>
			</view>
		</view>
		</scroll-view>

 	</view>
</template>

<script>
	import {getCoupon,receiveCoupon} from "@/api/user"
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import {
		collectDriList,
		delCollectDri
	} from '@/api/user'
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				list: [],
				selectlist:[],
				downOption: {
					use: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				allselect:true,
				havecontent: false,
				upOption: {},
			   cartype:9,
			   couponid:"a",
			}
		},
		created() {
			this.getdata()
		},
		onLoad(option) {
			if(option){
				this.cartype=option.cartype
				this.couponid=option.couponid
			}
		
		},
		methods: {
			routerNext(type){
				if(type==1){
					uni.navigateTo({
						url:"bundle/pages/discount_card/discount_card"
					})
				}else{
					uni.navigateTo({
						url:"bundle/pages/exchange_coupon/exchange_coupon"
					})
				}
			},
			async setCoupon(opt){
				this.list[opt.index].is_get=1
				await receiveCoupon({coupon_id:opt.id})
				this.$toast({
					title:"领取优惠卷成功"
				})
			},
			async getdata(){
				let res =await getCoupon()
				this.list=res.data.lists
			}
			
		},
	
	}
</script>

<style lang="scss" scoped>
	.scorll-height{
		height: 100vh;
		width: 100%;
		background-image: url(https://vkceyugu.cdn.bspapp.com/VKCEYUGU-e06d9f07-22c4-452d-8fbb-6dcc4e87be48/4c2c66f2-ca03-46b5-8d60-f4667411eaee.png) !important;
        background-size: cover;
	}
	.select-icon{
		
		
		width: 40rpx;
		height: 40rpx;
		border-radius: 30rpx;
		background-color: #E85631;
	}
	.noselect-icon{
		width: 40rpx;
		height: 40rpx;
		border-radius: 30rpx;
		border: 4rpx solid #C3C3C3;
	}
	.search-box{
		height: 84rpx;
		position: fixed;
		top: 36rpx;
		padding-right: 60rpx;
		padding-left: 60rpx;
		
		width: 100%;
		
	}
	.apply-time {
		width: 224rpx;
		height: 40rpx;
		border-radius: 12rpx;
		background-color: #F4F4F4;
		color: #807E7E;
	}

	.name-phone {
		justify-content: space-between;
		width: 460rpx;
	}

 .search-txt{
	 margin-right: 40rpx;
	 position: relative;
	 
 }
 .search-txt::after{
	 content: "";
	 position: absolute;
	 background-color: #ECECEC ;
	 width: 2rpx;
	 left: -16rpx;
	 top: 0rpx;
	 height: 48rpx;
 }
	.mescroll-empty {
		display: none !important;
	}

	.collect-btn {
		border: 2rpx;
		border-radius: 10rpx;
		color: #EE6841;

		border: 3rpx solid #EE6841;
	}

	.search-content {
		height:100%;
		justify-content: space-between;
		border: 2rpx solid #4D8EFB;
		top: 0rpx;
		width:100%;
		background-color: #FFFFFF;
	}


</style>
